declare @KEHOACH Table(
	ID int,
	DON_VI_ID int,
	[CHI_TIEU_ID] int
)
	insert into @KEHOACH
	SELECT ID,DON_VI_ID, [CHI_TIEU_ID]
	FROM [NV].[KEHOACH]
	WHERE [NAM_KE_HOACH_ID] = 2016 and STATUS_ID=10 and 
	[CHI_TIEU_ID] in (select [CHI_TIEU_ID] from [NV].[DONVI_CHITIEU] 
	where [NAM_KE_HOACH_ID] = 2016 and [DON_VI_ID]  = 43 and FLAG = 1)
	order by CHI_TIEU_ID

declare @R3 Table(
	
	DON_VI_ID int,
	[CHI_TIEU_ID] int
)

insert into @R3
select DON_VI_ID, CHI_TIEU_ID from @KEHOACH t
group by DON_VI_ID, CHI_TIEU_ID
HAVING COUNT(*)>1

declare @R4 Table(
	ID int,
	DON_VI_ID int,
	[CHI_TIEU_ID] int
)

insert into @R4
select distinct * from @KEHOACH
where DON_VI_ID in (select DON_VI_ID from @R3) and
CHI_TIEU_ID in  (select CHI_TIEU_ID from @R3) 

select * from @R4

